package com.shyfu;

import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
public class Utils {

    public static String getContextPath(HttpServletRequest request) {
        return request.getSession().getServletContext().getContextPath();
    }

    public static String getCoversPath(HttpServletRequest request) {
        return getContextPath(request) + "/" + Constants.COVER_IMAGE_PATH;
    }

    public static String getBookFilesPath(HttpServletRequest request) {
        return getContextPath(request) + "/" + Constants.BOOK_FILE_PATH;
    }

    public static String getUserImagesPath(HttpServletRequest request) {
        return getContextPath(request) + "/" + Constants.USER_IMAGE_PATH;
    }

    public static String getAuthorImagesPath(HttpServletRequest request) {
        return getContextPath(request) + "/" + Constants.AUTHOR_IMAGE_PATH;
    }
}